package com.example.siyun.controller.shouyecontroller;

import com.example.siyun.pojo.Loginlog;
import com.example.siyun.service.impl.shouyeserviceimpl.LoginlogServiceImpl;
import com.example.siyun.util.JsonResult;
import com.example.siyun.util.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @Auther: 全
 * @Date: 2022/9/26 09:33
 * @Description:首页的登录日志
 */
@Slf4j
@RestController
public class LoginlogController {
    @Autowired
    private LoginlogServiceImpl loginlogService;
    /**
     * 获取登录日志信息
     * @param page 第几页, limit 一页几条数据
     * @return 返回登录日志的数据
     */
    @RequestMapping("/advanced/getall")
    public PageResult getAll(int page, int limit) {
        log.info("获取登录日志信息");
        PageHelper.startPage(page, limit);
        List<Loginlog> list = loginlogService.getLog();
        PageInfo<Loginlog> pageInfo = new PageInfo<>(list);
        PageResult pageResult=new PageResult();
        pageResult.setState(0);
        pageResult.setMessage("成功");
        pageResult.setTotal(pageInfo.getTotal());
        pageResult.setData(pageInfo.getList());
        log.info("获取登录日志信息成功");
        return pageResult;
    }
}
